package com.cjy.graphics;

import java.io.PrintStream;

public class TestGeometricObject {

    public static void main(String[] args) {

        GeometricObject geoObject1 = new Circle(5.0);//圆
        GeometricObject geoObject2 = new Rectangle(5.0, 3.0);//矩形
        GeometricObject geoObject3 = new Cube(6.0);//正方形

        System.out.println("The two objects have the same area? " + equalArea(geoObject1, geoObject2));
        equalArea(geoObject1, geoObject2);

        // Display circle
        displayGeometricObject(geoObject1);

        // Display rectangle
        displayGeometricObject(geoObject2);
        // Display cube
        displayGeometricObject(geoObject3);

        //面积最大值
        thanSize(geoObject1, geoObject2, geoObject3);

        //最小值
        thanSize2(geoObject1, geoObject2, geoObject3);
    }

    public static void thanSize2(GeometricObject geoObject1, GeometricObject geoObject2, GeometricObject geoObject3) {
        double v = geoObject1.getPerimeter() < geoObject2.getPerimeter() ? geoObject1.getPerimeter() : geoObject2.getPerimeter();
        double s = v < geoObject3.getPerimeter() ? v : geoObject3.getPerimeter();
        System.out.println("\n最小周长值为：" + s);
    }

    public static void thanSize(GeometricObject geoObject1, GeometricObject geoObject2, GeometricObject geoObject3) {
        double v = geoObject1.getArea() > geoObject2.getArea() ? geoObject1.getArea() : geoObject2.getArea();
        double s = v > geoObject3.getArea() ? v : geoObject3.getArea();
        System.out.println("\n最大面积值为：" + s);
    }

    public static boolean equalArea(GeometricObject object1, GeometricObject object2) {
        return object1.getArea() == object2.getArea();
    }

    public static void displayGeometricObject(GeometricObject object) {
        System.out.println();
        System.out.println("The area is " + object.getArea());
        System.out.println("The perimeter is " + object.getPerimeter());
    }
}
